﻿using System;
using Loki.UI;
using Loki.UI.Win;

namespace Luna.UI.Win
{
    /// <summary>
    /// Logon view.
    /// </summary>
    public partial class LogonView : LunaView, IView<LogonViewModel>
    {
        public LogonView()
        {
            InitializeComponent();
            BindingChanged += LogonView_BindingChanged;
        }

        private void LogonView_BindingChanged(object P_Sender, EventArgs e)
        {
            TXT_Login.BindValue(ViewModel, x => x.Login);
            TXT_Password.BindValue(ViewModel, x => x.Password);
        }

        public new LogonViewModel ViewModel
        {
            get { return (LogonViewModel)base.ViewModel; }
            set { base.ViewModel = value; }
        }

        private void BTN_Cancel_Click(object P_Sender, EventArgs e)
        {
            ViewModel.Cancel.Execute(null);
        }

        private void BTN_OK_Click(object P_Sender, EventArgs e)
        {
            ViewModel.Logon.Execute(null);
        }
    }
}
